﻿using System.Text;
using System.Text.RegularExpressions;

namespace Pathfinder.Utilities
{
    public static class StringExtensions
    {
        /// <summary>
        /// Strips all of the HTML from a string.
        /// </summary>
        /// <param name="self">String to strip.</param>
        /// <param name="regexExpression">Regular expression to use to replace.</param>
        /// <returns>Stripped string.</returns>
        public static string StripHTML(this string self, string regexExpression)
        {
            StringBuilder stringBuilder = new StringBuilder();
            foreach (string brSplit in Regex.Split(self, "<br.*?>", RegexOptions.IgnoreCase | RegexOptions.Singleline))
            {
                stringBuilder.AppendLine(brSplit);
            }
            return Regex.Replace(stringBuilder.ToString(), regexExpression, "", RegexOptions.IgnoreCase | RegexOptions.Singleline);
        }

        //"<.+?>"
        //"((?<=</a>)|(?<=^)).+?((?=<a href=\"http://www.d20pfsrd.com/bestiary/monster-listings/)|(?=$))"
    }
}
